package com.tianpengtech.common.mock.impl.string;




import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.tianpengtech.common.mock.impl.AbstractNumberMock;
import com.tianpengtech.common.mock.impl.AbstractStringMock;
import com.tianpengtech.common.mock.impl.numberic.IntegerMock;
import com.tianpengtech.common.util.EngineUtil;

public class ChineseTitleMock extends AbstractStringMock{

	private String file ;
	public ChineseTitleMock(String file){
		this.file = file;
	}
	@Override
	public String mockData() {
		String content = EngineUtil.readFileContent(file,null);
		AbstractNumberMock<Integer> imock = new IntegerMock();
		JSONArray news = JSON.parseArray(content);
		int index = imock.mockData(0, news.size());
		String title="";
		if(index<news.size()){
			JSONObject obj =  (JSONObject) news.get(index);
			title = obj.getString("title");
		}
		return title;
	}

}
